package merge;

import org.apache.hadoop.io.NullWritable;
import org.apache.hadoop.mapreduce.Reducer;

import java.io.IOException;

/**
 * 获取到map阶段拿到key对应的结果集自己在遍历一次输出
 */
public class MergeReduce extends Reducer<MergeBean, NullWritable, NullWritable, MergeBean> {
    int position = 0;
    @Override
    protected void reduce(MergeBean key, Iterable<NullWritable> values, Context context) throws IOException, InterruptedException {
        for (NullWritable i : values) {
            position += 1;
            key.setPosition(position);
            context.write(NullWritable.get(),key);
        }
    }
}
